package com.yupi.yuoj.model.vo;

import com.yupi.yuoj.model.entity.LearningHistory;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import org.springframework.beans.BeanUtils;

/**
 * 学习历史视图
 *
 * @author jingjin
 */
@Data
public class LearningHistoryVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 内容 id
     */
    private Long contentId;

    /**
     * 用户 id
     */
    private Long userId;

    /**
     * 学习进度（百分比，0-100）
     */
    private Integer progress;

    /**
     * 学习时长（分钟）
     */
    private Integer studyDuration;

    /**
     * 最后学习位置
     */
    private String lastPosition;

    /**
     * 是否完成
     */
    private Integer isCompleted;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 内容信息
     */
    private ContentVO content;

    /**
     * 用户信息
     */
    private UserVO user;

    /**
     * 包装类转对象
     *
     * @param learningHistoryVO
     * @return
     */
    public static LearningHistory voToObj(LearningHistoryVO learningHistoryVO) {
        if (learningHistoryVO == null) {
            return null;
        }
        LearningHistory learningHistory = new LearningHistory();
        BeanUtils.copyProperties(learningHistoryVO, learningHistory);
        return learningHistory;
    }

    /**
     * 对象转包装类
     *
     * @param learningHistory
     * @return
     */
    public static LearningHistoryVO objToVo(LearningHistory learningHistory) {
        if (learningHistory == null) {
            return null;
        }
        LearningHistoryVO learningHistoryVO = new LearningHistoryVO();
        BeanUtils.copyProperties(learningHistory, learningHistoryVO);
        return learningHistoryVO;
    }

    private static final long serialVersionUID = 1L;
}